import pygame, sys, math

class HealthBar(pygame.sprite.Sprite):
    def __init__(self, pos = (0,0)):
        pygame.sprite.Sprite.__init__(self, self.containers)
        self.value = 100
        self.images = [pygame.image.load("rsc/healthbar/healthbar100.png"),
                       pygame.image.load("rsc/healthbar/healthbar85.png"),
                       pygame.image.load("rsc/healthbar/healthbar70.png"),
                       pygame.image.load("rsc/healthbar/healthbar55.png"),
                       pygame.image.load("rsc/healthbar/healthbar40.png"),
                       pygame.image.load("rsc/healthbar/healthbar25.png"),
                       pygame.image.load("rsc/healthbar/healthbar10.png"),
                       pygame.image.load("rsc/healthbar/healthbar0.png")]
        self.image = self.images[0]
        self.image = pygame.transform.scale(self.image, [200, 25])
        self.rect = self.image.get_rect()
        self.x = pos[0]
        self.y = pos[1]
        self.place(pos)
        
    def place(self, pos):
        self.rect.center = pos
        
    def fixLocation(self, x, y):
        pass
        
    def update(*args):
        self = args[0]
        if self.value != args[8]:
            self.value = args[8]
            
            if self.value > 85:
                self.image = self.images[0]
            elif self.value > 70:
                self.image = self.images[1]
            elif self.value > 55:
                self.image = self.images[2]
            elif self.value > 40:
                self.image = self.images[3]
            elif self.value > 25:
                self.image = self.images[4]
            elif self.value > 10:
                self.image = self.images[5]
            elif self.value > 0:
                self.image = self.images[6]
            self.image = pygame.transform.scale(self.image, [200, 25])
        
        
        
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    

